const totree = require('totree')

const data = [{
  id: 371,
  parentId: 0,
  menuname: "菜单1"
},
{
  id: 372,
  parentId: 371,
  menuname: "菜单1-1"
},
{
  id: 374,
  parentId: 0,
  menuname: "菜单2"
},
{
  id: 375,
  parentId: 374,
  menuname: "菜单2-1"
},
{
  id: 376,
  parentId: 0,
  menuname: "菜单3"
},
{
  id: 377,
  parentId: 376,
  menuname: "菜单3-1"
},
{
  id: 378,
  parentId: 376,
  menuname: "菜单3-2"
},
{
  id: 379,
  parentId: 376,
  menuname: "菜单3-3"
},
{
  id: 380,
  parentId: 376,
  menuname: "菜单3-4"
},
{
  id: 381,
  parentId: 0,
  menuname: "菜单4"
},
{
  id: 382,
  parentId: 381,
  menuname: "菜单4-1"
},
{
  id: 383,
  parentId: 381,
  menuname: "菜单4-2"
}
]


let res = totree(data);
console.dir(res);
